package com.guozcc.gateway.autofilter.autogatewayfilter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;


/***
 * 第一个全局请求报文过滤器,
 * 对收到的请求报文，进行get请求方式以及参数必填项校验
 * -104
 */
@Component
public class AutoGatewayAfterZeroFilter implements GatewayFilter , Ordered {
    private final Logger log = LoggerFactory.getLogger(this.getClass());


    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("局部过滤器前置执行： "+this.getClass().getSimpleName());
        return chain.filter(exchange).then(Mono.fromRunnable(() -> {
            log.info("局部过滤器后置执行： "+this.getClass().getSimpleName());
        }));
    }

    @Override
    public int getOrder() {
        return 1;
    }
}
